package com.leve.admin.service;

import com.leve.admin.domain.Comment;
import com.leve.admin.domain.Reply;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.NO_CONTENT;

@FeignClient(value = "space", path = "v1/")
public interface SpaceService {


    @ApiOperation(value = "创建此刻的点赞")
    @PutMapping(value = "posts/{post_id}/votes/{ghost_id}")
    @ResponseStatus(CREATED)
    @ResponseBody
    void createVote(@PathVariable("post_id") String post_id, @PathVariable("ghost_id") String ghost_id);

    @ApiOperation("根据此刻查询评论列表")
    @GetMapping(value = "posts/{post_id}/comments")
    @ResponseBody
    List<Comment> findCommentsByPost(@PathVariable("post_id") String post_id,
                                     @RequestParam("user_id") String user_id,
                                     @RequestParam(value = "page") int page,
                                     @RequestParam(value = "size") int size);

    @ApiOperation("删除此刻")
    @DeleteMapping("posts/{post_id}")
    @ResponseStatus(NO_CONTENT)
    void deletePost(@PathVariable("post_id") String post_id);

    @ApiOperation(value = "★创建评论")
    @PostMapping(value = "posts/{post_id}/comments")
    Comment createComment(@ApiParam(value = "此刻标识", required = true)
                          @PathVariable("post_id") String post_id,
                          @RequestBody @Valid Comment comment);


    @ApiOperation(value = "★创建评论回复<user字段变更为author>")
    @PostMapping(value = "posts/{post_id}/comments/{comment_id}/replies")
    Reply createReply(@ApiParam(value = "此刻标识", required = true)
                      @PathVariable("post_id") String postId,
                      @ApiParam(value = "评论标识", required = true)
                      @PathVariable("comment_id") String commentId,
                      @Valid @RequestBody Reply reply);
}
